package com.example.onlinemusicserver2024.controller;

import com.example.onlinemusicserver2024.common.R;
import com.example.onlinemusicserver2024.model.domain.RankList;
import com.example.onlinemusicserver2024.service.RankListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class RankListController {

    @Autowired
    RankListService rankListService;

    /**
     * 根据用户id获取歌单的评价
     * @param consumerId
     * @param songListId
     * @return
     */
    @GetMapping("/rankList/user")
    public R getUserRankList(@RequestParam int consumerId, @RequestParam int songListId) {
        R result = rankListService.getUserRankList(consumerId,songListId);
        return result;
    }

    /**
     * 获取歌单的平均评分
     * @param songListId
     * @return
     */
    @GetMapping("/rankList")
    public R getAvgScore(@RequestParam int songListId){
        R result = rankListService.getAvgScore(songListId);
        return result;

    }

    /**
     * 评分
     * @param rankList
     * @return
     */
    @PostMapping("/rankList/add")
    public R addRankList(@RequestBody RankList rankList){
        R result = rankListService.addRankList(rankList);
        return result;
    }
}
